#ifndef CLIENTSOCKET_H
#define CLIENTSOCKET_H

#include <QTcpSocket>
#include "tunnel_mainwindow.h"
#include "chathandler.h"
#include "tunnel_struckts.h"

class ChatHandler;
class ClientSocket : public QTcpSocket
{
    Q_OBJECT

public:
    ClientSocket(QObject *parent = 0);
    ~ClientSocket();

    bool startAndConnect();
    bool fillPackage(Package *package, QDataStream *incommingStream);
    void sendPackage(Package *package);
    inline void setupSystemPackage(Package *package, QString commandCategorie, QString command, QString arguments)
    {
        package->typ              = "System";
        package->commandCategorie = commandCategorie;
        package->command          = command;
        package->arguments        = arguments;
    }
    inline ChatHandler *getChatHandler() { return m_chatHandler; }

private:
    quint16 dataSize;
    ChatHandler *m_chatHandler;

signals:
    void cSocketError(QString error);

private slots:
    void readSocket();
    void on_authCommand(QString arguments);

};


#endif // CLIENTSOCKET_H
